<!doctype html>
<html>
	<head>
		<title>text/uri-list conversion</title>
		<style type="text/css">
div { height: 100px; width: 100px; background: orange; }
		</style>
		<script type="text/javascript">
window.onload = function () {
	var drag = document.getElementsByTagName('div')[0], fails = [];
	drag.ondragstart = function (e) {
		e.dataTransfer.setData('url','http://example.com/');
		if( !e.dataTransfer.getData('url') ) {
			document.getElementsByTagName('p')[0].innerHTML = "FAIL - getData('url') returned nothing";
		} else if( e.dataTransfer.getData('url') != e.dataTransfer.getData('text/uri-list') ) {
			document.getElementsByTagName('p')[0].innerHTML = 'FAIL - text/uri-list is not the same as url';
		} else {

			e.dataTransfer.setData('url','#foo\r\n http://example.com/#bar \r\n http://example.org/');
			if( e.dataTransfer.getData('url') != 'http://example.com/#bar' ) {
				document.getElementsByTagName('p')[0].innerHTML = 'FAIL - only the first URL should be returned - "'+e.dataTransfer.getData('url')+'"';
			} else if( e.dataTransfer.getData('text/uri-list') != '#foo\r\n http://example.com/#bar \r\n http://example.org/' ) {
				document.getElementsByTagName('p')[0].innerHTML = 'FAIL - text/uri-list should return the full data';
			} else {

				e.dataTransfer.setData('url',' ');
				if( e.dataTransfer.getData('url') ) {
					document.getElementsByTagName('p')[0].innerHTML = 'FAIL - space was not a valid URL so an empty string should have been returned';
				} else {
					document.getElementsByTagName('p')[0].innerHTML = 'PASS';
				}

			}

		}
		e.preventDefault();
	};
};
		</script>
	</head>
	<body>
		<div draggable="true"></div>
		<p>Attempt to drag the orange square.</p>
		<noscript><p>Enable JavaScript and reload</p></noscript>
	</body>
</html>